import http from '@/utils/http'

const BASE_URL = '/settlement/salaryLog'

export interface SalaryLogResp {
    id: string
    salary: string
    employeeId: string
    createTime: string
    createUserString: string
    updateUserString: string
    disabled: boolean
}

export interface SalaryLogDetailResp {
    id: string
    todoId: string
    employeeId: string
    salary: string
    status: string
    createUser: string
    createTime: string
    createUserString: string
    updateUserString: string
}

export interface SalaryLogQuery {
    sort: Array<string>
}

export interface SalaryLogPageQuery extends SalaryLogQuery, PageQuery {
    employeeId: string
    status: string
}

/** @desc 查询工资发放记录列表 */
export function listSalaryLog(query: SalaryLogPageQuery) {
    return http.get<PageRes<SalaryLogResp[]>>(BASE_URL, query)
}

/** @desc 查询工资发放记录列表 */
export function listSalaryLogByUserId(query: SalaryLogPageQuery) {
    return http.get<PageRes<SalaryLogResp[]>>(BASE_URL, query)
}

/** @desc 查询工资发放记录详情 */
export function getSalaryLog(id: string) {
    return http.get<SalaryLogDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增工资发放记录 */
export function addSalaryLog(data: any) {
    return http.post(BASE_URL, data)
}

/** @desc 修改工资发放记录 */
export function updateSalaryLog(data: any, id: string) {
    return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除工资发放记录 */
export function deleteSalaryLog(id: string) {
    return http.del(BASE_URL, {ids: [id]})
}

/** @desc 导出工资发放记录 */
export function exportSalaryLog(query: SalaryLogQuery) {
    return http.download(`${BASE_URL}/export`, query)
}
